<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script src="./2.js"></script>
</head>

<body>
    姓名：<input type="text" id="name"><br><br>
    语文：<input type="text" id="china"><br><br>
    数学：<input type="text" id="math"><br><br>
    英语：<input type="text" id="english"><br><br>
    <button id="btn">提交</button><br><br>
    <div id="main" style="width:700px; height:500px"></div>
</body>
<script>
    $("#btn").click(function () {
        var name = $("#name").val()
        var china = parseFloat($('#china').val())
        var math = parseFloat($('#math').val())
        var english = parseFloat($('#english').val())
        var total = china + math + english

        var myChart = echarts.init(document.getElementById('main'));

        var option = {
            title: {
                text: '学生分数统计'
            },
            tooltip: {},   //鼠标移上显示数据
            legend: {
                data: ['语文', '数学', '英语', '总分']
            },
            xAxis: {
                // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                data: [name]
            },
            yAxis: {},
            series: [
                {
                    name: '语文',
                    type: 'bar',
                    data: [china]
                },
                {
                    name: '数学',
                    type: 'bar',
                    data: [math]
                },
                {
                    name: '英语',
                    type: 'bar',
                    data: [english]
                },
                {
                    name: '总分',
                    type: 'bar',
                    data: [total]
                },
            ]
        };
        myChart.setOption(option);
    })
</script>

</html>